
<extend name="public:base" />
<block name="breadcrumb">
    <ul class="breadcrumb">
        <li>
            <i class="ace-icon fa fa-book"></i>
            <a href="index">{:L('数据库管理')}</a>
        </li>
        <li class="active">{:L('数据库还原')}</li>
    </ul>
</block>
<block name="c-block">
    <div class="main-content">
            <!-- #section:settings.box -->

            <!-- /.ace-settings-container -->

            <!-- /section:settings.box -->
            <div class="page-content-area">

                <div class="page-header">
                    <h1>
                        数据库管理            <small>
                        <i class="ace-icon fa fa-angle-double-right"></i>
                        数据库还原            </small>
                        <!-- <ul class="nav navbar-nav navbar-right">
                            <button class="btn btn-sm btn-primary" onclick="openDialog('{:U('adminAdd')}', '新增用户');">
                                <i class="fa fa-plus"></i> 新增用户 </button>
                        </ul> -->
                    </h1>

                </div>

                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                          
                        <table id="sample-table-1" class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                
                                <th>文件名称</th>
                                <th>文件大小</th>
                                <th>备份时间</th>
                                <th>卷号</th>
                               
                                <th class="text-right">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="lists" id="vo" empty="暂没相关数据">
                                <tr id="id_{$vo.id}">
                                
                                    <td>{$vo['name']}</td>
                                    <td >{$vo['sortSize']}</td>
                                    <td>{$vo['time']}</td>
                                    <td >{$vo['number']}</td>
                                    
                                    <td class="text-right">
                                        
                                        <a class="btn btn-xs btn-info" href="{:U('downFile',['type'=>'sql','file'=>$vo['name']])}">
                                            <i class="ace-icon fa fa-cloud-download bigger-120"></i> 下载
                                        </a>
                                        <button class="btn btn-xs btn-danger delete confirm" data-rel="确定删除该备份吗?" data-action="{:U('delSqlFiles',['sqlfilename'=>$vo['name']])}">
                                            <i class="ace-icon fa fa-trash-o bigger-120"></i> 删除
                                        </button>
                                    </td>
                                </tr>
                            </volist>
                            
                            </tbody>
                        </table>
                        <!-- PAGE CONTENT ENDS -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content-area -->
    </div>
</block>



{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>备份文件列表</legend>
    </fieldset>
    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
{include file="common/foot"/}
<script type="text/html" id="size">
    {{d.sortSize}}
</script>
<script type="text/html" id="action">
    <a class="layui-btn layui-btn-normal layui-btn-mini" lay-event="recover">恢复</a>
    <a href="{:url('downFile')}?type=sql&file={{d.name}}" class="layui-btn layui-btn-mini">下载</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">{:lang('del')}</a>
</script>
<script>
    layui.use('table', function() {
        var table = layui.table, $ = layui.jquery;
        table.render({
            elem: '#list'
            ,url: '{:url("restore")}',
            method:'post'
            ,cols: [[
                {field:'name', title: '文件名称', width:250}
                ,{field:'size', title: '文件大小', width:200,sort:true,templet:'#size'}
                ,{field:'time', title: '备份时间', width:200,sort:true}
                ,{field:'number', title: '卷号', width:150}
                ,{width:160, align:'center', toolbar: '#action'}
            ]]
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if (obj.event === 'recover') {
                loading = layer.load(1, {shade: [0.1, '#fff']});
                layer.confirm('确认要导入数据吗？',{icon: 0}, function (index) {
                    $.post("{:url('restoreData')}",{sqlfilepre:data.name},function(res){
                        layer.close(loading);
                        if(res.code==1){
                            layer.msg(res.msg, {time: 1000,icon:1});
                        }else{
                            layer.msg(res.msg, {time: 1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }else if(obj.event === 'del'){
                layer.confirm('确认要删除该备份文件吗？', {icon: 3}, function (index) {
                    loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post('{:url("delSqlFiles")}',{sqlfilename: data.name}, function (res) {
                        layer.close(loading);
                        if (res.code == 1) {
                            layer.msg(res.msg, {time: 1000,icon:1});
                            obj.del();
                        }else{
                            layer.msg(res.info,{time: 1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });
    });
</script>